import Vue from 'vue';
import iView from 'iview';
import {router} from './router/index';
import store from './store';
import App from './app.vue';
import './theme/index.less';
import util from './libs/util';

Vue.use(iView);
Vue.directive('has', {
    bind: function(el, binding,vnode) {
        let permissions=vnode.context.$route.meta.permission;
        if (permissions && permissions.length && !permissions.includes(binding.value)) {
            el.parentNode.removeChild(el);
        }
    }
});
new Vue({
    el: '#app',
    router: router,
    store: store,
    render: h => h(App),
    data: {
        currentPageName: ''//当前选项的名字
    },
    mounted () {
        this.currentPageName = this.$route.name;
        // 显示打开的页面的列表
        this.$store.commit('setOpenedList');
        this.$store.commit('initCachepage');
        // 权限菜单过滤相关
        util.initRouter(this);
    },
    created () {

    }
});
